<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>我的生活</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css">
    <style type="text/css">
        input {
            border-radius: 4px !important;
        }
    </style>
</head>
<body>
<div class="page-group">
    <div class="page page-current">
        <div class="content">
            <img style="width: 100%; height: auto;" src="../resource/hotui/img/reporter_logo.jpeg">
            <div class="list-block" style="margin: -7px 0;">
                <ul>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-name"></i></div>
                            <div class="item-inner" style="padding-bottom: .7rem;padding-top: .7rem;">
                                <div class="item-title label">所在学校</div>
                                <div class="item-input">
                                    <input type="text" id="school" style="border: 1px solid #ccc;" placeholder="所在学校">
                                </div>
                            </div>
                        </div>
                    </li>
                    <!--<li>-->
                    <!--<div class="item-content">-->
                    <!--<div class="item-media"><i class="icon icon-form-email"></i></div>-->
                    <!--<div class="item-inner">-->
                    <!--<div class="item-title label">所在年级</div>-->
                    <!--<div class="item-input">-->
                    <!--<select id="gradeType">-->
                    <!--<option th:each="gradeType:${gradeTypes}" th:text="${gradeType.desc}" th:value="${gradeType.code}">一年级</option>-->
                    <!--</select>-->

                    <!--</div>-->
                    <!--</div>-->
                    <!--</div>-->
                    <!--</li>-->
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-password"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">所在班级</div>
                                <div class="item-input">
                                    <input type="text" style="border: 1px solid #ccc;" id="className" placeholder="所在班级">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-password"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">小记者姓名</div>
                                <div class="item-input">
                                    <input type="text" style="border: 1px solid #ccc;" id="reporterName" placeholder="小记者姓名">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-password"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">小记者证号</div>
                                <div class="item-input">
                                    <input type="text" style="border: 1px solid #ccc;" id="reporterNum" placeholder="小记者证号">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-password"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">指导老师</div>
                                <div class="item-input">
                                    <input type="text" style="border: 1px solid #ccc;" id="teacher" placeholder="指导老师">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-password"></i></div>
                            <div class="item-inner">
                                <div class="item-title label">投稿标题</div>
                                <div class="item-input">
                                    <input style="border: 1px solid #ccc;" type="text" id="title" placeholder="投稿标题">
                                </div>
                            </div>
                        </div>
                    </li>
                    <li class="align-top" style="padding-bottom: 15px;">
                        <div class="item-content">
                            <div class="item-media"><i class="icon icon-form-comment"></i></div>
                            <div class="item-inner">
                                <div class="item-input">
                                    <textarea id="content" style="margin-top: 15px;border: 1px solid #ccc;height: 11rem;" placeholder="投稿内容"></textarea>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="content-block">
                <div class="row">
                    <div><a href="javascript:submitForm()" class="button button-big button-fill button-success">提交</a></div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script>
<script type="text/javascript" th:inline="javascript">
    var ajaxUri = /*[[@{/submit}]]*/ 1;
    var currentPage = /*[[@{/fList}]]*/ "";
</script>
<script type="text/javascript">
    function submitForm() {
        var school = $.trim($("#school").val());
        if (school.length == 0) {
            $.toast("请填写所在学校");
            return;
        }
        var className = $.trim($("#className").val());
        if (className.length == 0) {
            $.toast("请填写所在班级");
            return;
        }
        var reporterName = $.trim($("#reporterName").val());
        if (reporterName.length == 0) {
            $.toast("请填写小记者名称");
            return;
        }
        var reporterNum = $.trim($("#reporterNum").val());
        if (reporterNum.length == 0) {
            $.toast("请填写小记者证件号");
            return;
        }
        var teacher = $.trim($("#teacher").val());
        if (teacher.length == 0) {
            $.toast("请填写指导老师");
            return;
        }
        var title = $.trim($("#title").val());
        if (title.length == 0) {
            $.toast("请填写稿件标题");
            return;
        }
        var content = $("#content").val();
        if (content.length == 0) {
            $.toast("请填写稿件内容");
            return;
        }
        var requestData = {
            school: school,
            // gradeType: $("#gradeType").val(),
            className: className,
            reporterName: reporterName,
            reporterNum: reporterNum,
            teacher: teacher,
            title: title,
            content: encodeURI(content)
        };

        $.ajax({
            type: "post",
            url: ajaxUri,
            data: requestData,
            dataType: 'json',
            success: function (data) {
                if (data == 1) {
                    $.alert("提交成功");
                    window.location.href = currentPage;
                }
            },
            error: function () {

            }
        });
    }
</script>
</body>
</html>